package com.system.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

@Configuration
public class MYThreadPool {
    @Bean("carSocketExecutor")
    public ExecutorService carSocketExecutor() {
        int processors = Runtime.getRuntime().availableProcessors();
        return new ThreadPoolExecutor(processors, 1000,
                10, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>());
    }

    @Bean("cachedExecutor")
    public ExecutorService cachedExecutor() {
        return Executors.newCachedThreadPool();
    }

}
